package br.ufpe.cin.mac.parser.xml;

import br.ufpe.cin.mac.parser.Binds;
import br.ufpe.cin.mac.parser.CanonicalElements;
import br.ufpe.cin.mac.parser.XBind;
import br.ufpe.cin.mac.parser.XComponent;
import br.ufpe.cin.mac.parser.XConnector;
import br.ufpe.cin.mac.parser.XMiddleware;

public class XmlTest {

	public static void main(String args[]) {

		XMiddleware mid = new XMiddleware("1");
		CanonicalElements elements = new CanonicalElements();
		Binds binds = new Binds();

		XComponent comp1 = new XComponent("Teste", "Cryptography");
		XComponent comp2 = new XComponent("Teste", "Decryptography");
		elements.addXComponent(comp1);
		elements.addXComponent(comp2);

		XConnector conn1 = new XConnector("Teste", "Reliable");
		XConnector concreteConnector = new XConnector("Concrete", "Connector");
		elements.addXConnector(conn1);
		elements.addConcreteConnector(concreteConnector);

		XBind bind1 = new XBind("1", comp1.getName(), comp2.getName(), conn1
				.getName());
		binds.addBind(bind1);

		mid.setCanonicalElements(elements);
		mid.setBinds(binds);

		XmlWriter xml = new XmlWriter();

		xml.writeXML(mid, "Config.xml");

		// Testando o Reader
		XmlReader xml2 = new XmlReader();

		XMiddleware mid2 = xml2.readXml("Config.xml");

		xml.writeXML(mid2, "Config2.xml");

	}

}
